import { createRouter, createWebHashHistory } from "vue-router";
import BlankLayout from "@/layout/blank.vue";
import Layout from "@/layout/index.vue";

const routes = [
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/login/login.vue"),
  },
  {
    path: "/",
    name: "index",
    redirect: "/task/list",
    component: Layout,
    children: [
      {
        path: "/task/list",
        name: "task",
        meta: { title: "任务管理", icon: "ContainerOutlined" },
        component: () => import("@/views/task/index.vue"),
      },
      {
        path: "/task/edit",
        name: "taskEdit",
        meta: { title: "编辑项目", hideInMenu: true },
        component: () => import("@/views/task/edit.vue"),
      },
      {
        path: "/task/add",
        name: "taskAdd",
        meta: { title: "新增项目", hideInMenu: true },
        component: () => import("@/views/task/edit.vue"),
      },
      {
        path: "/task/setting",
        name: "taskSetting",
        meta: { title: "设置抽样", hideInMenu: true },
        component: () => import("@/views/task/setting.vue"),
      },
      {
        path: "/user",
        name: "user",
        meta: { title: "用户管理", icon: "UserOutlined" },
        component: BlankLayout,
        redirect: "/user/user",
        children: [
          {
            path: "/user/user",
            name: "userUser",
            meta: { title: "会员管理" },
            component: () => import("@/views/user/index.vue"),
          },
          {
            path: "/user/user/detail",
            name: "userDetail",
            meta: { title: "会员详情", hideInMenu: true },
            component: () => import("@/views/user/detail.vue"),
          },
          {
            path: "/user/customer",
            name: "userCustomer",
            meta: { title: "客户管理" },
            component: () => import("@/views/user/customer.vue"),
          },
          {
            path: "/user/admin",
            name: "userAdmin",
            meta: { title: "后台管理员" },
            component: () => import("@/views/user/admin.vue"),
          },
        ],
      },
      {
        path: "/record",
        name: "record",
        meta: { title: "记录管理", icon: "DatabaseOutlined" },
        component: BlankLayout,
        redirect: "/record/recomment",
        children: [
          {
            path: "/record/recomment",
            name: "recordRecomment",
            meta: { title: "推荐记录" },
            component: () => import("@/views/record/recomment.vue"),
          },
          {
            path: "/record/complete",
            name: "recordComplete",
            meta: { title: "参与记录" },
            component: () => import("@/views/record/complete.vue"),
          },
          {
            path: "/record/jifen",
            name: "recordJifen",
            meta: { title: "积分记录" },
            component: () => import("@/views/record/jifen.vue"),
          },
          {
            path: "/record/audit",
            name: "recordAudit",
            meta: { title: "认证审核记录" },
            component: () => import("@/views/record/audit.vue"),
          },
        ],
      },
      {
        path: "/product",
        name: "product",
        meta: { title: "商品管理", icon: "ShoppingOutlined" },
        component: BlankLayout,
        redirect: "/product/index",
        children: [
          {
            path: "/product/index",
            name: "productShop",
            meta: { title: "商品管理" },
            component: () => import("@/views/product/index.vue"),
          },
          {
            path: "/product/record",
            name: "productRecord",
            meta: { title: "商品兑换" },
            component: () => import("@/views/product/record.vue"),
          },
          {
            path: "/product/recordDetail",
            name: "productRecordDetail",
            meta: { title: "兑换审核", hideInMenu: true },
            component: () => import("@/views/product/recordDetail.vue"),
          },
        ],
      },
      {
        path: "/other",
        name: "other",
        meta: { title: "其他", icon: "SettingOutlined" },
        component: BlankLayout,
        redirect: "/other/index",
        children: [
          {
            path: "/other/banner",
            name: "banner",
            meta: { title: "banner管理" },
            component: () => import("@/views/other/banner.vue"),
          },
          {
            path: "/other/qa",
            name: "qa",
            meta: { title: "常见问题管理" },
            component: () => import("@/views/other/qa.vue"),
          },
        ],
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
